use chrono::prelude::*;
use std::{collections::HashMap, thread::sleep, time::Duration};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    tracing_subscriber::fmt()
        .with_max_level(tracing::Level::DEBUG)
        .init();
    tracing::info!("RRAI 启动...");

    // let mut temp_buffer = vec![0u8; 376];
    // Utc::now().timestamp() - c.updated > Duration::minutes(2).num_milliseconds()
    // tracing::debug!("{}", Utc::now().;
    // tracing::debug!("{}", chrono::Duration::minutes(2).num_milliseconds());
    // let mut buf:Vec<u8> = vec![0;500];
    // buf[0..375].copy_from_slice(&temp_buffer[0..376]);

    let token = String::from("eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyaWQiOiI1OTEyMDg4ZTQ4YmM0MGFjODQ2MjJiMzMwZTg0MTc1ZiIsInVuaW9uaWQiOiJvbXVSV3c4N2w1Q3ZacVhaZmFTbmVzRnVXZVBvIiwib3BlbmlkIjoib2VDTEo1a0FkM0d5RnN2bDhRWWF0WTZIS3RzRSIsImV4cCI6MTcxMDgxNDU5MTMwN30.eXKKXqklU0W9vKH1xuHqNu37clEbeqpebfF17jg1zZY");

    let _ = model_graph_peer::peer_start().await;

    let result = model_graph_peer::peer_login(&token).await;

    match result {
        Ok(result) => {
            tracing::debug!("peer login:{:?}", result);
        }
        Err(err) => tracing::error!("login fail:{:?}", err),
    }

    tokio::select! {
        _ = tokio::signal::ctrl_c() => {
            println!();
        }
    };
    tracing::info!("RRAI 结束...");
    Ok(())
}
